home *** CD-ROM | disk | FTP | other *** search
/ C/C++ Users Group Library 1996 July / C-C++ Users Group Library July 1996.iso / vol_300 / 343_02 / strappnd.c < prev    next >
C/C++ Source or Header  |  1990-08-10  |  1KB  |  50 lines

  1.  
  2. /*
  3.  * NAME: append_string (string1, string2)
  4.  *
  5.  * FUNCTION: Appends the contents of string1 to the contents
  6.  *           of string2.
  7.  *
  8.  * EXAMPLE:  string1    string2 before   string2 after
  9.  *           " there!"      "Hello"      "Hello there!"
  10.  *
  11.  *           append_string (string1, string2);
  12.  *
  13.  * VARIABLES USED:  string1: string to append.
  14.  *                  string2: string being appended to.
  15.  *                  index1:  index into string1.
  16.  *                  index2:  index into string2.
  17.  *
  18.  * PSEUDO CODE:  initialize index2 to 0
  19.  *
  20.  *               while (string2[index2] is not NULL)
  21.  *                  increment index2  -- to find the end of string2
  22.  *
  23.  *               initialize index1 to 0
  24.  *
  25.  *               while (string2[index2] is assigned the letter in
  26.  *                      string1[index1] and the letter is not NULL)
  27.  *                  increment index1 and index2
  28.  *
  29.  */
  30.  
  31. #include "d:\cips\cips.h"
  32.  
  33.  append_string (string1, string2)
  34.    char string1[];          /* string to append */
  35.    char string2[];                 /* string appended to */
  36.   {
  37.    int index1;       /* current location in string1 */
  38.    int index2;    /* current location in string2 */
  39.  
  40.    /* find the end of string2 */
  41.  
  42.    for (index2 = 0; string2[index2] != '\0'; index2++)
  43.      ;
  44.  
  45.    /* append string1 to string2 */
  46.  
  47.    for (index1 = 0;(string2[index2] = string1[index1])!= '\0'; ++index1)
  48.        ++index2;   /* also increment string2 */
  49.   }
  50.